from dvb3 import frontend, dmx

import channels
import sys
import gtk

channel = sys.argv[1]

c = channels.Channels()
c.read(open("/home/nigel/channels.conf"))

fe = frontend.Frontend(0)
dm = dmx.Demux(0)
dm2 = dmx.Demux(0)

fe.set_frontend(c.get_parameter(channel))

dm.set_pes_filter(c.get_vpid(channel), dmx.DMX_IN_FRONTEND, dmx.DMX_OUT_TS_TAP, dmx.DMX_PES_VIDEO, dmx.DMX_IMMEDIATE_START)
dm2.set_pes_filter(c.get_apid(channel), dmx.DMX_IN_FRONTEND, dmx.DMX_OUT_TS_TAP, dmx.DMX_PES_AUDIO, dmx.DMX_IMMEDIATE_START)

dm.start()
dm2.start()

gtk.main()
